<template>
  <div>
    <!-- 测量特性定义表单弹窗 -->
    <el-dialog
      :close-on-click-modal="false"
      v-model="visibleDialog"
      :title="props.title"
      draggable
      style="width: 1400px"
      align-center
      @close="closeDialog"
    >
      <el-form ref="formRef" :model="formData" :rules="rules" label-width="160">
        <el-row>
          <el-col
            :span="12"
            style="border-right: 1px dashed black; padding-right: 20px"
          >
            <el-descriptions
              class="margin-top"
              title=""
              :column="3"
              size="default"
              border
            >
              <el-descriptions-item label="工段"
                >{{ formData.workshopSectionCode }}
              </el-descriptions-item>
              <el-descriptions-item label="工序"
                >{{ formData.processCode }}
              </el-descriptions-item>
              <el-descriptions-item label="生产线"
                >{{ formData.equipCode }}
              </el-descriptions-item>

              <el-descriptions-item :span="2" label="型号描述">
                {{ formData.modelName }}
              </el-descriptions-item>
              <el-descriptions-item :span="1" label="产品型号"
                >{{ formData.modelCode }}
              </el-descriptions-item>
              <!-- <el-descriptions-item :span="2" label="检具类别">
                {{ formData.groupCode }}
              </el-descriptions-item> -->
              <el-descriptions-item :span="2" label="检具类别">
                {{ formData.groupCode }}
              </el-descriptions-item>
              <el-descriptions-item :span="1" label="检具用途">
                {{
                  dictionaryStore.filterDictName(
                    "samplingStatus",
                    formData.useType ?? ""
                  )
                }}
              </el-descriptions-item>
              <el-descriptions-item :span="2" label="特性名称">
                <el-tag size="default">{{ formData.paramName }}</el-tag>
              </el-descriptions-item>
              <el-descriptions-item :span="1" label="公称尺寸">
                {{ formData.parameterStandards }}
              </el-descriptions-item>
              <el-descriptions-item :span="3" label="责任人">
                {{ formData.responsibleUserName }}
              </el-descriptions-item>
              <!-- <el-descriptions-item v-if="props.isReadonly" label="备注" :span="4">
            {{ formData.remarks }}
          </el-descriptions-item> -->
              <el-descriptions-item v-if="props.isReadonly" label="公差上限">
                {{ formData.upperLimitValue ?? "" }}
              </el-descriptions-item>
              <el-descriptions-item
                v-if="props.isReadonly"
                label="控制线上限收严比例"
              >
                {{ formData.controlRatioUp ?? ""
                }}{{ formData.controlRatioUp ? "%" : "" }}
              </el-descriptions-item>
              <el-descriptions-item v-if="props.isReadonly" label="控制限上限">
                {{ formData.controlUp ?? "" }}
              </el-descriptions-item>

              <el-descriptions-item v-if="props.isReadonly" label="公差下限">
                {{ formData.lowerLimitValue ?? "" }}
              </el-descriptions-item>
              <el-descriptions-item
                v-if="props.isReadonly"
                label="控制线下限收严比例"
              >
                {{ formData.controlRatioDown ?? ""
                }}{{ formData.controlRatioDown ? "%" : "" }}
              </el-descriptions-item>
              <el-descriptions-item v-if="props.isReadonly" label="控制限下限">
                {{ formData.controlDown ?? "" }}
              </el-descriptions-item>
              <el-descriptions-item v-if="props.isReadonly" label="修改人">
                {{ formData.lastUpdatedUserName }}
              </el-descriptions-item>
              <el-descriptions-item
                :span="3"
                v-if="props.isReadonly"
                label="修改时间"
              >
                {{ formData.lastUpdateTime }}
              </el-descriptions-item>
              <el-descriptions-item
                v-if="props.isReadonly"
                label="CPK计算"
                :span="4"
              >
                <el-tag
                  size="default"
                  v-if="formData.isCalculate"
                  :type="!formData.isCalculate ? 'info' : ''"
                  class="mr-[7px]"
                  >是
                </el-tag>
                <el-tag
                  size="default"
                  v-else
                  :type="!formData.isCalculate ? 'info' : ''"
                  class="mr-[7px]"
                  >否
                </el-tag>
              </el-descriptions-item>
              <el-descriptions-item
                v-if="props.isReadonly"
                label="预警工单"
                :span="4"
              >
                <el-tag
                  size="default"
                  class="mr-[7px]"
                  v-if="formData.isSingleOrder && hasTag('单值')"
                  :type="!formData.isSingleOrder ? 'info' : ''"
                  >单值
                </el-tag>
                <el-tag
                  size="default"
                  v-if="formData.isAverageOrder && hasTag('均值')"
                  :type="!formData.isAverageOrder ? 'info' : ''"
                  class="mr-[7px]"
                  >均值
                </el-tag>
                <el-tag
                  size="default"
                  v-if="formData.isLongOrder && hasTag('长期过程能力')"
                  :type="!formData.isLongOrder ? 'info' : ''"
                  class="mr-[7px]"
                  >长期过程能力
                </el-tag>
                <el-tag
                  size="default"
                  v-if="formData.isStageOrder && hasTag('短期能力')"
                  :type="!formData.isStageOrder ? 'info' : ''"
                  class="mr-[7px]"
                  >短期能力
                </el-tag>
                <!-- <el-tag
                  size="default"
                  v-if="formData.isFeaturesOrder && hasTag('子类别过程能力')"
                  :type="!formData.isFeaturesOrder ? 'info' : ''"
                  class="mr-[7px]"
                  >子类别过程能力
                </el-tag> -->
              </el-descriptions-item>
              <el-descriptions-item
                v-if="props.isReadonly"
                label="预警邮件"
                :span="4"
              >
                <el-tag
                  size="default"
                  class="mr-[7px]"
                  v-if="formData.isSingle && hasTag('单值')"
                  :type="!formData.isSingle ? 'info' : ''"
                  >单值
                </el-tag>
                <el-tag
                  size="default"
                  v-if="formData.isAverage && hasTag('均值')"
                  :type="!formData.isAverage ? 'info' : ''"
                  class="mr-[7px]"
                  >均值
                </el-tag>
                <el-tag
                  size="default"
                  v-if="formData.isLong && hasTag('长期过程能力')"
                  :type="!formData.isLong ? 'info' : ''"
                  class="mr-[7px]"
                  >长期过程能力
                </el-tag>
                <el-tag
                  size="default"
                  v-if="formData.isStage && hasTag('短期能力')"
                  :type="!formData.isStage ? 'info' : ''"
                  class="mr-[7px]"
                  >短期能力
                </el-tag>
                <!-- <el-tag
                  size="default"
                  v-if="formData.isFeatures && hasTag('子类别过程能力')"
                  :type="!formData.isFeatures ? 'info' : ''"
                  class="mr-[7px]"
                  >子类别过程能力
                </el-tag> -->
              </el-descriptions-item>
            </el-descriptions>
            <!-- <el-row>
          <el-col :span="6">
            <el-form-item label="工序" prop="equipCode" label-width="80">
              <span>{{ formData.processCode }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="生产线" prop="equipCode" label-width="80">
              <span>{{ formData.equipCode }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="产品型号" prop="equipName" label-width="80">
              <span>{{ formData.modelCode }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="产品描述" prop="equipName" label-width="80">
              <span>{{ formData.modelName }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="检具编号" prop="equipName" label-width="80">
              <span>{{ formData.gageEquipMarkCode }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="检具用途" prop="equipName" label-width="80">
              <span>{{ formData.gageEquipMarkName }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="特性" prop="equipName" label-width="80">
              <span>{{ formData.paramName }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="公称尺寸" prop="equipName" label-width="80">
              <span>{{ formData.parameterStandards }}</span>
            </el-form-item>
          </el-col>
        </el-row> -->
            <el-row v-if="!props.isReadonly" class="mt-[20px]">
              <el-col :span="8">
                <el-form-item
                  prop="ruleLowestDuration"
                  label="公差上限"
                  label-width="80"
                >
                  <el-input
                    disabled
                    v-model="formData.upperLimitValue"
                    placeholder="公差上限"
                    clearable
                    style="width: 90%"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item
                  prop="ruleLowestDuration"
                  label="控制线上限收严比例"
                  label-width="140"
                >
                  <el-input
                    :disabled="props.isReadonly"
                    v-model="formData.controlRatioUp"
                    placeholder="控制线上限收严比例"
                    clearable
                    @input="numValidcontrolRatioUp()"
                    type="number"
                    :suffixIcon="() => '%'"
                  />
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item
                  prop="ruleLowestDuration"
                  label="控制限上限"
                  label-width="120"
                >
                  <el-input
                    disabled
                    v-model="formData.controlUp"
                    placeholder="控制限上限"
                    clearable
                  />
                </el-form-item>
              </el-col>
            </el-row>

            <el-row v-if="!props.isReadonly">
              <el-col :span="8">
                <el-form-item
                  prop="ruleLowestDuration"
                  label="公差下限"
                  label-width="80"
                >
                  <el-input
                    disabled
                    v-model="formData.lowerLimitValue"
                    placeholder="公差下限"
                    clearable
                    style="width: 90%"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item
                  prop="ruleLowestDuration"
                  label="控制线下限收严比例"
                  label-width="140"
                >
                  <el-input
                    :disabled="props.isReadonly"
                    v-model="formData.controlRatioDown"
                    placeholder="控制线下限收严比例"
                    clearable
                    @input="numValidcontrolRatioDown()"
                    type="number"
                    :suffixIcon="() => '%'"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item
                  prop="ruleLowestDuration"
                  label="控制限下限"
                  label-width="120"
                >
                  <el-input
                    disabled
                    v-model="formData.controlDown"
                    placeholder="控制限下限"
                    clearable
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row v-if="!props.isReadonly">
              <el-form-item label="CPK计算" label-width="80">
                <el-checkbox
                  :disabled="props.isReadonly"
                  v-model="formData.isCalculate"
                >
                </el-checkbox>
              </el-form-item>
            </el-row>
            <el-row style="margin-top: 0" v-if="!props.isReadonly">
              <el-col :span="24" class="warning-select">
                <el-form-item label="生成工单" label-width="80">
                  <el-checkbox
                    :disabled="props.isReadonly"
                    v-model="selectAllWo"
                    @change="handleCheckAllWoChange"
                    >全选
                  </el-checkbox>
                  <el-checkbox
                    v-for="(item, index) in tabsList"
                    :key="index"
                    :disabled="props.isReadonly"
                    v-model="formData[`${item.labelValue}Order`]"
                    @change="handleCheckAllChange1"
                    >{{ item.label }}
                  </el-checkbox>
                </el-form-item>
                <el-form-item label="发送邮件" label-width="80">
                  <el-checkbox
                    :disabled="props.isReadonly"
                    v-model="selectAllEm"
                    @change="handleCheckAllEmChange"
                    >全选
                  </el-checkbox>
                  <el-checkbox
                    v-for="(item, index) in tabsList"
                    :key="index"
                    :disabled="props.isReadonly"
                    v-model="formData[item.labelValue]"
                    @change="handleCheckAllChange2"
                    >{{ item.label }}
                  </el-checkbox>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>

          <el-col :span="12" style="padding-left: 20px">
            <el-tabs
              type="border-card"
              v-model="tabSelected"
              :class="props.isReadonly ? 'readForm' : ''"
              v-if="tabsList && tabsList.length"
            >
              <el-tab-pane
                v-for="(item, index) in tabs.filter(
                  (t) => t.toolUseType == formData.useType
                )"
                :label="item.label"
                :name="item.name"
                :key="index"
              >
                <el-row>
                  <!-- 过程质量监控分类 -->
                  <el-col :span="11">
                    <el-form-item label="过程质量监控分类">
                      <el-select
                        v-if="!props.isReadonly"
                        v-model="item.abilityTypeElder"
                        placeholder="请选择过程质量监控分类"
                        clearable
                        disabled
                        style="width: 100%"
                      >
                        <el-option
                          v-for="item in dictionaryStore.filterDictList(
                            'AbilityTypeMin'
                          )"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        />
                      </el-select>
                      <span v-else>{{
                        dictionaryStore.filterDictName(
                          "AbilityTypeMin",
                          item.abilityTypeElder
                        ) || ""
                      }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" />
                  <!-- 检具用途 -->
                  <el-col :span="11">
                    <el-form-item label="检具用途">
                      <el-select
                        v-if="!props.isReadonly"
                        style="width: 100%"
                        disabled
                        v-model="item.toolUseType"
                        placeholder="请选择量检具用途"
                        clearable
                      >
                        <el-option
                          v-for="item in useDictionary('samplingStatus')"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        />
                      </el-select>
                      <span v-else>{{
                        dictionaryStore.filterDictName(
                          "samplingStatus",
                          item.toolUseType
                        ) || ""
                      }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" />
                  <!-- 监控描述 -->
                  <el-col :span="23">
                    <el-form-item label="监控描述">
                      <el-input
                        v-if="!props.isReadonly"
                        v-model="item.memo"
                        placeholder="请输入监控描述"
                        clearable
                        type="textarea"
                      />
                      <span v-else>{{ item.memo }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" />
                </el-row>
                <!-- 单值 -->
                <el-row
                  v-if="item.abilityType == '0' || item.abilityType == '1'"
                >
                  <el-col :span="11">
                    <el-form-item label="控制线上限收严比例" prop="upLine">
                      <el-input
                        v-model="item.upLine"
                        placeholder="控制线上限收严比例"
                        clearable
                        :suffixIcon="() => '%'"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.upLine }}</span>
                    </el-form-item>
                  </el-col>

                  <el-col :span="1" />
                  <el-col :span="11">
                    <el-form-item label="控制线下限收严比例" prop="downLine">
                      <el-input
                        v-model="item.downLine"
                        placeholder="控制线下限收严比例"
                        clearable
                        :suffixIcon="() => '%'"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.downLine }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" />
                  <el-col :span="11">
                    <el-form-item label="单值默认展示数量" prop="sampleNum">
                      <el-input
                        v-model="item.sampleNum"
                        placeholder="请输入单值默认展示数量"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.sampleNum }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" />

                  <el-col :span="11">
                    <el-form-item label="取样数据集上限" prop="maxCount">
                      <el-input
                        v-model="item.maxCount"
                        placeholder="取样数据集上限"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.maxCount }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" />
                  <el-col :span="11">
                    <el-form-item label="取样频度">
                      <el-input
                        disabled
                        v-model="formData.samplingFrequency"
                        placeholder="取样频度"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>100%</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" />
                </el-row>

                <!-- 均值 -->
                <el-row
                  v-if="item.abilityType == '2' || item.abilityType == '3'"
                >
                  <el-col :span="11">
                    <el-form-item label="均值默认展示数量" prop="sampleNum">
                      <el-input
                        v-model="item.sampleNum"
                        placeholder="请输入均值默认展示数量"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.sampleNum }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" />
                  <el-col :span="11">
                    <el-form-item label="子组样本数量" prop="groupingNum">
                      <el-input
                        v-model="item.groupingNum"
                        placeholder="请输入子组样本数量"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.groupingNum }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" />
                  <el-col :span="11">
                    <el-form-item label="取样数据集上限" prop="sampleNum">
                      <el-input
                        v-model="item.maxCount"
                        placeholder="取样数据集上限"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.maxCount }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" />
                  <el-col :span="11">
                    <el-form-item label="取样频度">
                      <el-input
                        disabled
                        v-model="formData.samplingFrequency"
                        placeholder="取样频度"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>100%</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" />
                </el-row>

                <!-- 短期显示 -->
                <el-row v-if="item.abilityType == '6'">
                  <el-col :span="11">
                    <el-form-item label="计算样本最低数量" prop="ruleLowestNum">
                      <el-input
                        v-if="!props.isReadonly"
                        v-model="item.ruleLowestNum"
                        placeholder="请输入计算样本最低数量"
                        clearable
                      />
                      <span v-else>{{ item.ruleLowestNum }}</span>
                    </el-form-item>
                  </el-col>

                  <el-col :span="1">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图能够开始计算的最小采样数"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>

                  <el-col :span="11">
                    <el-form-item
                      :label="
                        item.abilityType != '3'
                          ? '滚动数量'
                          : '样本节拍比对件数'
                      "
                      prop="continuousNum"
                    >
                      <el-input
                        v-if="!props.isReadonly"
                        v-model="item.continuousNum"
                        :placeholder="`请输入${
                          item.abilityType != '3'
                            ? '滚动数量'
                            : '样本节拍比对件数'
                        }`"
                        clearable
                      />
                      <span v-else>{{ item.continuousNum }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      :content="`${
                        item.abilityType == '3'
                          ? '达到最大范围后，舍弃最早数据'
                          : '趋势图每次采样采集数据，之前必须是连续个数'
                      }`"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>
                </el-row>

                <!--   长期100%检-->
                <el-row
                  v-if="item.abilityType == '4' && item.toolUseType == '2'"
                >
                  <el-col :span="11">
                    <el-form-item
                      label="首次执行时间"
                      prop="firstExecutionTime"
                    >
                      <el-date-picker
                        style="width: 100%"
                        v-model="item.firstExecutionTime"
                        :disabled="true"
                        type="datetime"
                        placeholder="请选择首次执行时间"
                        format="YYYY-MM-DD HH"
                        value-format="YYYY-MM-DD HH"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.firstExecutionTime }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" />
                  <el-col
                    :span="11"
                    v-if="item.abilityType != '3' && item.abilityType != 7"
                  >
                    <el-form-item label="取样间隔（小时）" prop="intervalHour">
                      <el-input
                        v-model="item.intervalHour"
                        placeholder="请输入取样间隔（小时）"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.intervalHour }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col
                    :span="1"
                    v-if="item.abilityType != '3' && item.abilityType != 7"
                  >
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="进行采样的间隔时间"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>
                  <el-col :span="11" v-if="item.abilityType < '5'">
                    <el-form-item
                      :label="
                        !item.abilityType != '3'
                          ? '滚动数量'
                          : '样本节拍比对件数'
                      "
                      prop="continuousNum"
                    >
                      <el-input
                        v-model="item.continuousNum"
                        :placeholder="`请输入${
                          !item.abilityType != '3'
                            ? '滚动数量'
                            : '样本节拍比对件数'
                        }`"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.continuousNum }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" v-if="item.abilityType < '5'">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      :content="`${
                        !item.abilityType != '3'
                          ? '达到最大范围后，舍弃最早数据'
                          : '趋势图每次采样采集数据，之前必须是连续个数'
                      }`"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>
                  <el-col
                    :span="11"
                    v-if="item.abilityType != '3' && item.abilityType < 5"
                  >
                    <el-form-item label="节拍比对倍数" prop="intervalSecond">
                      <el-input
                        v-model="item.intervalSecond"
                        placeholder="请输入节拍比对倍数"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.intervalSecond }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col
                    :span="1"
                    v-if="item.abilityType != '3' && item.abilityType < 5"
                  >
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图采样数量之间时间间隔小于，则合格采样"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>
                  <el-col :span="11">
                    <el-form-item label="计算样本最低数量" prop="ruleLowestNum">
                      <el-input
                        v-model="item.ruleLowestNum"
                        placeholder="请输入计算样本最低数量"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.ruleLowestNum }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图能够开始计算的最小采样数"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>

                  <el-col :span="11" v-if="item.abilityType != '3'">
                    <el-form-item
                      label="CPK计算周期（小时）"
                      prop="cpkComputeHour"
                    >
                      <el-input
                        v-model="item.cpkComputeHour"
                        placeholder="请输入CPK计算周期（小时）"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.cpkComputeHour }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" v-if="item.abilityType != '3'">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图首次计算后，进行CPK计算的间隔时间"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>
                  <!-- 
                  <el-col
                    :span="11"
                    v-if="item.abilityType != '3' && item.abilityType != '4'"
                  >
                    <el-form-item
                      label="计算最低取样时长(天)"
                      prop="ruleLowestDuration"
                    >
                      <el-input
                        v-model="item.ruleLowestDuration"
                        placeholder="请输入计算最低取样时长(天)"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.ruleLowestDuration }}</span>
                    </el-form-item>
                  </el-col>

                  <el-col
                    :span="1"
                    v-if="item.abilityType != '3' && item.abilityType != '4'"
                  >
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图能够开始计算的最小采样时间"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col> -->

                  <el-col :span="11" v-if="item.abilityType != '3'">
                    <el-form-item label="取样最大范围" prop="maxRange">
                      <el-input
                        v-model="item.maxRange"
                        placeholder="请输入取样最大范围"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.maxRange }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" v-if="item.abilityType != '3'">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图计算采样数最大范围（按月或按采样数量）"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>
                  <!-- <el-col :span="11" v-if="item.abilityType != '3'">
                    <el-form-item label="取样最小范围" prop="minRange">
                      <el-input
                        v-model="item.minRange"
                        placeholder="请输入取样最小范围"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.minRange }}</span>
                    </el-form-item>
                  </el-col>

                  <el-col :span="1" v-if="item.abilityType != '3'">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图计算采样数最小范围（按月或按采样数量）"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col> -->
                  <el-col :span="11" v-if="item.abilityType != '3'">
                    <el-form-item label="取样范围单位" prop="maxUnit">
                      <el-select
                        v-model="item.maxUnit"
                        placeholder="请选择取样范围单位"
                        clearable
                        style="width: 100%"
                        v-if="!props.isReadonly"
                      >
                        <el-option
                          v-for="item in dictionaryStore.filterDictList(
                            'MaxUnit'
                          )"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        />
                      </el-select>
                      <span v-else>{{
                        dictionaryStore.filterDictName(
                          "MaxUnit",
                          item.maxUnit
                        ) || ""
                      }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" v-if="item.abilityType != '3'">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="取样范围的单位（月/采样个数）"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>
                </el-row>
                <!--  长期抽检 -->
                <el-row
                  v-if="item.abilityType == '4' && item.toolUseType == '1'"
                >
                  <!-- 首次执行时间 -->
                  <el-col :span="11">
                    <el-form-item
                      label="首次执行时间"
                      prop="firstExecutionTime"
                    >
                      <el-date-picker
                        style="width: 100%"
                        v-model="item.firstExecutionTime"
                        :disabled="true"
                        type="datetime"
                        placeholder="请选择首次执行时间"
                        format="YYYY-MM-DD HH"
                        value-format="YYYY-MM-DD HH"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.firstExecutionTime }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" />
                  <!-- 计算最低取样时长(天) -->
                  <el-col
                    :span="11"
                    v-if="item.abilityType != '3' && item.toolUseType != '2'"
                  >
                    <el-form-item
                      label="计算最低取样时长(天)"
                      prop="ruleLowestDuration"
                    >
                      <el-input
                        v-model="item.ruleLowestDuration"
                        placeholder="请输入计算最低取样时长(天)"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.ruleLowestDuration }}</span>
                    </el-form-item>
                  </el-col>

                  <el-col
                    :span="1"
                    v-if="item.abilityType != '3' && item.toolUseType != '2'"
                  >
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图能够开始计算的最小采样时间"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>
                  <!--计算样本最低数量  -->
                  <el-col :span="11">
                    <el-form-item label="计算样本最低数量" prop="ruleLowestNum">
                      <el-input
                        v-model="item.ruleLowestNum"
                        placeholder="请输入计算样本最低数量"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.ruleLowestNum }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图能够开始计算的最小采样数"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>
                  <!--CPK计算周期（小时）  -->
                  <el-col :span="11" v-if="item.abilityType != '3'">
                    <el-form-item
                      label="CPK计算周期（小时）"
                      prop="cpkComputeHour"
                    >
                      <el-input
                        v-model="item.cpkComputeHour"
                        placeholder="请输入CPK计算周期（小时）"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.cpkComputeHour }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" v-if="item.abilityType != '3'">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图首次计算后，进行CPK计算的间隔时间"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>

                  <!-- <el-col
                    :span="11"
                    v-if="item.abilityType != '3' && item.toolUseType > 1"
                  >
                    <el-form-item label="节拍比对倍数" prop="intervalSecond">
                      <el-input
                        v-model="item.intervalSecond"
                        placeholder="请输入节拍比对倍数"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.intervalSecond }}</span>
                    </el-form-item>
                  </el-col> -->
                  <!-- <el-col
                    :span="1"
                    v-if="item.abilityType != '3' && item.toolUseType > 1"
                  >
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图采样数量之间时间间隔小于，则合格采样"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col> -->
                  <!--取样最大范围  -->
                  <el-col :span="11" v-if="item.abilityType != '3'">
                    <el-form-item label="取样最大范围" prop="maxRange">
                      <el-input
                        v-model="item.maxRange"
                        placeholder="请输入取样最大范围"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.maxRange }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" v-if="item.abilityType != '3'">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图计算采样数最大范围（按月或按采样数量）"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>
                  <!-- 取样最小范围 -->
                  <el-col :span="11" v-if="item.abilityType != '3'">
                    <el-form-item label="取样最小范围" prop="minRange">
                      <el-input
                        v-model="item.minRange"
                        placeholder="请输入取样最小范围"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.minRange }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" v-if="item.abilityType != '3'">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图计算采样数最小范围（按月或按采样数量）"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>
                  <!-- <el-col :span="11" v-if="item.abilityType == '3'">
            <el-form-item label="取样范围滚动间隔" prop="rollInterval">
              <el-input
                v-model="formData.rollInterval"
                placeholder="请输入取样范围滚动间隔"
                clearable
              />
            </el-form-item>
          </el-col> -->
                  <!-- <el-col :span="1" v-if="item.abilityType == '3'">
            <el-popover
              placement="top-end"
              :width="200"
              trigger="hover"
              content="达到最大范围后，舍弃最早数据"
            >
              <template #reference>
                <span class="yellow-icon">
                  <el-icon><QuestionFilled /></el-icon>
                </span>
              </template>
            </el-popover>
          </el-col> -->
                  <!-- 取样范围单位 -->
                  <el-col :span="11" v-if="item.abilityType != '3'">
                    <el-form-item label="取样范围单位" prop="maxUnit">
                      <el-select
                        v-model="item.maxUnit"
                        placeholder="请选择取样范围单位"
                        clearable
                        style="width: 100%"
                        v-if="!props.isReadonly"
                      >
                        <el-option
                          v-for="item in dictionaryStore.filterDictList(
                            'MaxUnit'
                          )"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        />
                      </el-select>
                      <span v-else>{{
                        dictionaryStore.filterDictName(
                          "MaxUnit",
                          item.maxUnit
                        ) || ""
                      }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" v-if="item.abilityType != '3'">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="取样范围的单位（月/采样个数）"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>

                  <el-col :span="11" v-if="item.abilityType != '3'">
                    <el-form-item
                      label="测量后缀"
                      prop="shaftSuffixIds"
                      style="width: 100%"
                    >
                      <el-select
                        v-model="item.shaftSuffixIdsTwo"
                        placeholder="请选择测量后缀"
                        multiple
                        collapse-tags
                        collapse-tags-tooltip
                        :max-collapse-tags="1"
                        clearable
                        filterable
                        v-if="!props.isReadonly"
                        loading-text="加载中..."
                        style="width: 100%"
                      >
                        <el-option
                          v-for="item1 in specialInspectionList"
                          :key="item1.id"
                          :label="`${item1.shaftSuffix}-${item1.featureName}`"
                          :value="item1.id"
                        />
                      </el-select>
                      <span v-else>{{ item.shaftSuffixCodes }}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
                <!-- 其他显示  子类别 -->
                <el-row v-if="item.abilityType == '7'">
                  <el-col :span="11">
                    <el-form-item
                      label="首次执行时间"
                      prop="firstExecutionTime"
                    >
                      <el-date-picker
                        style="width: 100%"
                        v-model="item.firstExecutionTime"
                        :disabled="true"
                        type="datetime"
                        placeholder="请选择首次执行时间"
                        format="YYYY-MM-DD HH"
                        value-format="YYYY-MM-DD HH"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.firstExecutionTime }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" />
                  <el-col
                    :span="11"
                    v-if="item.abilityType != '3' && item.abilityType != '4'"
                  >
                    <el-form-item
                      label="计算最低取样时长(天)"
                      prop="ruleLowestDuration"
                    >
                      <el-input
                        v-model="item.ruleLowestDuration"
                        placeholder="请输入计算最低取样时长(天)"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.ruleLowestDuration }}</span>
                    </el-form-item>
                  </el-col>

                  <el-col
                    :span="1"
                    v-if="item.abilityType != '3' && item.abilityType != '4'"
                  >
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图能够开始计算的最小采样时间"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>
                  <el-col :span="11">
                    <el-form-item label="计算样本最低数量" prop="ruleLowestNum">
                      <el-input
                        v-model="item.ruleLowestNum"
                        placeholder="请输入计算样本最低数量"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.ruleLowestNum }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图能够开始计算的最小采样数"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>

                  <el-col :span="11" v-if="item.abilityType != '3'">
                    <el-form-item
                      label="CPK计算周期（小时）"
                      prop="cpkComputeHour"
                    >
                      <el-input
                        v-model="item.cpkComputeHour"
                        placeholder="请输入CPK计算周期（小时）"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.cpkComputeHour }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" v-if="item.abilityType != '3'">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图首次计算后，进行CPK计算的间隔时间"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>

                  <el-col :span="11" v-if="item.abilityType != '3'">
                    <el-form-item label="取样最大范围" prop="maxRange">
                      <el-input
                        v-model="item.maxRange"
                        placeholder="请输入取样最大范围"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.maxRange }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" v-if="item.abilityType != '3'">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图计算采样数最大范围（按月或按采样数量）"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>
                  <el-col :span="11" v-if="item.abilityType != '3'">
                    <el-form-item label="取样最小范围" prop="minRange">
                      <el-input
                        v-model="item.minRange"
                        placeholder="请输入取样最小范围"
                        clearable
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.minRange }}</span>
                    </el-form-item>
                  </el-col>

                  <el-col :span="1" v-if="item.abilityType != '3'">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="趋势图计算采样数最小范围（按月或按采样数量）"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>

                  <el-col :span="11" v-if="item.abilityType != '3'">
                    <el-form-item label="取样范围单位" prop="maxUnit">
                      <el-select
                        v-model="item.maxUnit"
                        placeholder="请选择取样范围单位"
                        clearable
                        style="width: 100%"
                        v-if="!props.isReadonly"
                      >
                        <el-option
                          v-for="item in dictionaryStore.filterDictList(
                            'MaxUnit'
                          )"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        />
                      </el-select>
                      <span v-else>{{
                        dictionaryStore.filterDictName(
                          "MaxUnit",
                          item.maxUnit
                        ) || ""
                      }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="1" v-if="item.abilityType != '3'">
                    <el-popover
                      placement="top-end"
                      :width="200"
                      trigger="hover"
                      content="取样范围的单位（月/采样个数）"
                    >
                      <template #reference>
                        <span class="yellow-icon">
                          <el-icon><QuestionFilled /></el-icon>
                        </span>
                      </template>
                    </el-popover>
                  </el-col>
                </el-row>
                <el-divider
                  content-position="left"
                  v-if="item.abilityType != ''"
                >
                  <div style="font-weight: 700">报警设置</div>
                </el-divider>
                <!-- 单值显示 -->
                <el-row
                  v-if="item.abilityType == '0' || item.abilityType == '1'"
                >
                  <el-col :span="11">
                    <el-form-item
                      :label-width="'220px'"
                      label="预警触发：连续超过控制限次数"
                      prop="controlRate"
                    >
                      <el-input
                        v-if="!props.isReadonly"
                        v-model="item.controlRate"
                        placeholder="预警触发：连续超过控制限次数"
                        clearable
                      />
                      <span v-else>{{ item.controlRate }}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
                <!-- 均值 -->
                <el-row
                  v-if="item.abilityType == '2' || item.abilityType == '3'"
                >
                  <el-col :span="11">
                    <el-form-item
                      :label-width="'220px'"
                      label="预警触发条件：偏移量"
                      prop="controlRate"
                    >
                      <el-input
                        v-if="!props.isReadonly"
                        v-model="item.controlRate"
                        placeholder="请输入预警触发条件：偏移量"
                        clearable
                        :suffixIcon="() => '%'"
                      />
                      <span v-else
                        >{{ item.controlRate
                        }}{{ item.controlRate ? "%" : "" }}</span
                      >
                    </el-form-item>
                  </el-col>
                </el-row>
                <!-- 长期 -->
                <el-row
                  v-if="
                    item.abilityType == '4' ||
                    item.abilityType == '5' ||
                    item.abilityType == '6' ||
                    item.abilityType == '7'
                  "
                  style="width: 100%"
                >
                  <el-col :span="11">
                    <el-form-item label="趋势图中cpk值低于" prop="controlRate">
                      <el-input
                        v-if="!props.isReadonly"
                        v-model="item.cpkLow"
                        placeholder="请输入预警触发: 趋势图中cpk值低于"
                        clearable
                      />
                      <span v-else>{{ item.cpkLow }}</span>
                    </el-form-item>
                  </el-col>

                  <el-col :span="1" />

                  <el-col :span="11">
                    <el-form-item label="趋势图中ppk值低于" prop="controlRate">
                      <el-input
                        v-if="!props.isReadonly"
                        v-model="item.ppkLow"
                        placeholder="请输入预警触发: 趋势图中ppk值低于"
                        clearable
                      />
                      <span v-else>{{ item.ppkLow }}</span>
                    </el-form-item>
                  </el-col>
                </el-row>

                <!-- 阶段 -->
                <el-row
                  v-if="item.abilityType == '6'"
                  style="display: flex; justify-content: center"
                >
                  <p style="width: 80%">
                    过程能力趋势图cpk均高于
                    <el-form-item
                      prop="defaultTall"
                      label-width="0"
                      :show-message="false"
                      style="display: inline-block; margin: 0"
                    >
                      <el-input
                        v-model="item.defaultTall"
                        style="width: 60px"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.defaultTall }}</span>
                    </el-form-item>
                    并且cpk连续
                    <el-form-item
                      prop="tallStopover"
                      label-width="0"
                      :show-message="false"
                      style="display: inline-block; margin: 0"
                    >
                      <el-input
                        v-model="item.tallStopover"
                        style="width: 60px"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.tallStopover }}</span>
                    </el-form-item>
                    次高于
                    <el-form-item
                      prop="successiveTall"
                      label-width="0"
                      :show-message="false"
                      style="display: inline-block; margin: 0"
                    >
                      <el-input
                        v-model="item.successiveTall"
                        style="width: 60px"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.successiveTall }}</span>
                    </el-form-item>
                    以上
                  </p>
                  <p style="width: 80%">
                    <!-- 第二段文字 -->

                    过程能力趋势图中的点均低于
                    <el-form-item
                      prop="defaultLow"
                      label-width="0"
                      :show-message="false"
                      style="display: inline-block; margin: 0"
                    >
                      <el-input
                        v-model="item.defaultLow"
                        style="width: 60px"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.defaultLow }}</span>
                    </el-form-item>
                    并且cpk连续
                    <el-form-item
                      prop="lowStopover"
                      label-width="0"
                      :show-message="false"
                      style="display: inline-block; margin: 0"
                    >
                      <el-input
                        v-model="item.lowStopover"
                        style="width: 60px"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.lowStopover }}</span>
                    </el-form-item>
                    次呈持续下降趋势
                  </p>
                  <!-- <el-col :span="18">
                    <el-form-item label="当超过控制限上下限，是否预警">
                      <el-switch
                        v-model="item.isWarn"
                        inline-prompt
                        :disabled="props.isReadonly"
                        active-value="1"
                        inactive-value="0"
                        active-text="是"
                        inactive-text="否"
                      />
                    </el-form-item>
                  </el-col> -->
                </el-row>
                <!-- 特殊 -->
                <el-row
                  v-if="item.abilityType == '7'"
                  style="display: flex; justify-content: center"
                >
                  <p style="width: 80%">
                    过程能力趋势图cpk均高于
                    <el-form-item
                      prop="defaultTall"
                      label-width="0"
                      style="display: inline-block; margin: 0"
                    >
                      <el-input
                        v-model="item.defaultTall"
                        style="width: 60px"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.defaultTall }}</span>
                    </el-form-item>
                    并且cpk连续
                    <el-form-item
                      prop="tallStopover"
                      label-width="0"
                      style="display: inline-block; margin: 0"
                    >
                      <el-input
                        v-model="item.tallStopover"
                        style="width: 60px"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.tallStopover }}</span>
                    </el-form-item>
                    次高于
                    <el-form-item
                      prop="successiveTall"
                      label-width="0"
                      style="display: inline-block; margin: 0"
                    >
                      <el-input
                        v-model="item.successiveTall"
                        style="width: 60px"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.successiveTall }}</span>
                    </el-form-item>
                    以上

                    <!-- 第二段文字 -->
                  </p>
                  <p style="width: 80%">
                    过程能力趋势图中的点均低于
                    <el-form-item
                      prop="defaultLow"
                      label-width="0"
                      style="display: inline-block; margin: 0"
                    >
                      <el-input
                        v-model="item.defaultLow"
                        style="width: 60px"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.defaultLow }}</span>
                    </el-form-item>
                    并且cpk连续
                    <el-form-item
                      prop="lowStopover"
                      label-width="0"
                      style="display: inline-block; margin: 0"
                    >
                      <el-input
                        v-model="item.lowStopover"
                        style="width: 60px"
                        v-if="!props.isReadonly"
                      />
                      <span v-else>{{ item.lowStopover }}</span>
                    </el-form-item>
                    次呈持续下降趋势
                  </p>
                </el-row>
              </el-tab-pane>
            </el-tabs>
          </el-col>
        </el-row>

        <div v-if="remarkList && remarkList.length" style="margin-left: 0px">
          <h4 class="mb-[5px] flex justify-between">
            <span class="text-[15px]">备注履历</span>
            <span
              style="
                font-weight: 700;
                font-size: 13px;
                color: #409eff;
                cursor: pointer;
                padding-left: 10px;
              "
              @click="showOperationRecord"
            >
              <i-ep-sort /> 排序
            </span>
          </h4>
          <el-table
            highlight-current-row
            border
            :data="remarkList"
            max-height="280"
            style="width: 100%"
          >
            <el-table-column
              prop="responsibleUserName"
              label="责任人"
              min-width="80"
              align="center"
            />
            <el-table-column
              prop="lastUpdateTime"
              label="日期、时间"
              width="160"
              align="center"
            />

            <el-table-column prop="remarks" label="变更原因" min-width="150" />
            <el-table-column label="变更内容" min-width="250">
              <template #default="scope">
                <div v-if="scope.row?.changeInfo?.diff">
                  <div
                    v-for="(item1, index) in scope.row.changeInfo.tabs"
                    :key="index"
                  >
                    <div
                      class="text-[14px] mb-[2px] mt-[10px] c-[#333]"
                      :class="index == 0 ? 'mt-[0px]!' : ''"
                    >
                      {{ item1 }}
                    </div>
                    <div
                      v-for="(item, index2) in scope.row.changeInfo.diff"
                      :key="index2"
                    >
                      <el-descriptions title="" :column="2" border size="small">
                        <div
                          v-for="(key, index3) in Object.keys(item)"
                          :key="index3"
                        >
                          <div v-if="item[key]?.label == item1">
                            <el-descriptions-item>
                              <template #label>
                                <div class="cell-item">
                                  {{ item[key]?.name }}
                                </div>
                              </template>
                              <div style="width: 100%; word-break: break-all">
                                <span class="c-[#666]">{{
                                  `${item[key]?.value1 || "空"}`
                                }}</span>
                                <span class="font-600 px-[5px] c-[#b1b3b8]"
                                  ><svg-icon icon-class="right" class="mr-0!"
                                /></span>
                                <span class="c-[#ff0000]">{{
                                  `${item[key]?.value2 || "空"}`
                                }}</span>
                              </div>
                            </el-descriptions-item>
                          </div>
                        </div>
                      </el-descriptions>
                    </div>
                  </div>
                </div>
              </template>
            </el-table-column>
            <!-- <el-table-column
              prop="workOrderStatus"
              label="工单状态"
              width="120"
              align="center"
            >
              <template #default="scope">
                {{
                  useDictionary(
                    "PsmOrderStatus",
                    scope.row.order.workOrderStatus ?? ""
                  ) || ""
                }}
              </template>
            </el-table-column>
            <el-table-column
              prop="abilityType"
              label="监控分类"
              min-width="120"
              show-overflow-tooltip
              align="center"
            >
              <template #default="scope">
                {{
                  useDictionary(
                    "AbilityTypeMin",
                    scope.row.order.abilityType ?? ""
                  )
                }}
              </template>
            </el-table-column> -->
            <el-table-column
              label="关联工单"
              prop="workInfo"
              min-width="100"
              show-overflow-tooltip
              align="center"
            >
              <template #default="scope">
                <!-- <span
                  @click="openDialogdetail(scope.row.order)"
                  class="underline cursor-pointer c-blue"
                  >{{ scope.row.order.workInfo || "" }}</span
                > -->

                <span
                  @click="openDialogdetail(scope.row.order)"
                  :class="
                    scope.row.order.id ? 'underline cursor-pointer  c-blue' : ''
                  "
                  >查看工单</span
                >
              </template>
            </el-table-column>
            <!-- <el-table-column
              label="工单生成时间"
              prop="createTime"
              width="160"
              align="center"
            >
              <template #default="scope">
                <span>{{ scope.row.order.createTime ?? "" }}</span>
              </template>
            </el-table-column>
            <el-table-column
              label="工单处理时间"
              prop="lastUpdateTime"
              width="160"
              align="center"
            >
              <template #default="scope">
                <span>{{ scope.row.order.lastUpdateTime ?? "" }}</span>
              </template>
            </el-table-column> -->
          </el-table>
        </div>
      </el-form>

      <template #footer>
        <div class="dialog-footer">
          <el-button
            v-if="!props.isReadonly"
            type="primary"
            :loading="loading"
            @click="handleSubmit"
            >确 定
          </el-button>
          <el-button @click="closeDialog">取 消</el-button>
        </div>
      </template>
    </el-dialog>
    <el-dialog
      v-model="dialogVisible"
      title="提示"
      width="700"
      :close-on-click-modal="false"
      draggable
      align-center
    >
      <div v-for="(item1, index) in tabsReal" :key="index">
        <div
          class="text-[15px] mb-[4px] mt-[12px] c-[#333]"
          :class="index == 0 ? 'mt-[0px]!' : ''"
        >
          {{ item1 }}
        </div>
        <div v-for="(item, index2) in diffData" :key="index2">
          <el-descriptions title="" :column="2" border>
            <div v-for="(key, index3) in Object.keys(item)" :key="index3">
              <div v-if="item[key]?.label == item1">
                <el-descriptions-item>
                  <template #label>
                    <div class="cell-item">{{ item[key]?.name }}</div>
                  </template>
                  <div style="width: 100%; word-break: break-all">
                    <span class="c-[#666]">{{
                      `${item[key]?.value1 || "空"}`
                    }}</span>
                    <span class="font-600 px-[5px] c-[#b1b3b8]"
                      ><svg-icon icon-class="right" class="mr-0!"
                    /></span>
                    <span class="c-[#ff0000]">{{
                      `${item[key]?.value2 || "空"}`
                    }}</span>
                  </div>
                </el-descriptions-item>
              </div>
            </div>
          </el-descriptions>
        </div>
      </div>
      <div>
        <div class="text-[15px] mb-[4px] mt-[12px] c-[#333]">
          <span class="c-[#ff0000]">*</span>变更内容说明(必填)
        </div>
        <el-input
          v-model="formData.remarks"
          style="width: 100%"
          :rows="2"
          type="textarea"
          placeholder="变更内容说明"
        />
      </div>
      <div>
        <div class="text-[15px] mb-[4px] mt-[12px] c-[#333]">工单关联</div>
        <el-select
          v-model="formData.orderId"
          placeholder="请选择工单"
          clearable
          style="width: 100%"
        >
          <el-option
            v-for="(item, index) in workOrderList"
            :key="index"
            :label="item.workInfo"
            :value="item.id"
          />
        </el-select>
      </div>
      <!-- <span>This is a message</span> -->
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="saveInfo">确 定</el-button>
        </div>
      </template>
    </el-dialog>

    <pcmWorkOrders-edit
      :key="dayjsValue"
      :visible="addDialog.visible"
      :title="addDialog.title"
      :data="addDialog.data"
      :is-readonly="addDialog.readvisible"
      @change-visible="changeVisible"
    />
  </div>
</template>

<script setup lang="ts">
import request from "@/utils/request";
import { useDictStoreHook } from "@/store/modules/dictionary";
import ConfigEditCommon from "@/views/pcm/common/ConfigEditCommon.vue";
import { useDictionary } from "@/utils/useTable";
import { QuestionFilled } from "@element-plus/icons-vue"; // 引入
import dayjs from "dayjs";
const dictionaryStore = useDictStoreHook();

defineOptions({
  name: "PCMPCMMEASUREFEATURESADDORUPDATE",
  inheritAttrs: false,
});

const isShow = (value) => {
  console.log(index);

  console.log(diffData.value);
  return true;
};

const emit = defineEmits(["reset-table", "change-visible"]);

const props = defineProps({
  visible: {
    type: Boolean,
    default: () => {
      return false;
    },
  },
  title: {
    type: String,
    default: () => {
      return "";
    },
  },
  data: {
    type: Object,
    default: () => {
      return {};
    },
  },
  isReadonly: {
    type: Boolean,
    default: () => {
      return false;
    },
  },
});

const visibleDialog = ref(false);
watch(
  () => props.visible,
  (newVal: boolean) => {
    visibleDialog.value = newVal;
    setTimeout(() => {
      formRef.value.clearValidate();
    }, 50);
  }
);

const rules = reactive({
  processId: [],
  processCode: [],
  processName: [],
  equipId: [],
  equipCode: [],
  equipName: [],
  projectId: [],
  projectCode: [],
  projectName: [],
  modelId: [],
  modelCode: [],
  modelName: [],
  gageEquipId: [],
  gageEquipCode: [],
  gageEquipName: [],
  gageEquipMarkId: [],
  gageEquipMarkCode: [],
  gageEquipMarkName: [],
  paramId: [],
  paramCode: [],
  paramName: [],
  checkType: [],
  parameterStandards: [],
  lowerLimitValue: [],
  upperLimitValue: [],
  controlRatioUp: [],
  controlRatioDown: [],
  controlUp: [],
  controlDown: [],
  isRatioUp: [],
  isRatioDow: [],
  isSingle: [],
  isAverage: [],
  isLong: [],
  isStage: [],
  isFeatures: [],
  version: [],
  enabled: [],
  deleted: [],
  createTime: [],
  createdUserId: [],
  createdUserName: [],
  lastUpdatedUserId: [],
  lastUpdatedUserName: [],
  lastUpdateTime: [],
  // countRuleCode: [
  //   { required: true, message: "请输入取样规则编码", trigger: "change" },
  //   { max: 20, message: "规则编码不能超过20个字符", trigger: "blur" },
  // ],
  // abilityType: [
  //   { required: true, message: "请选择过程质量监控分类", trigger: "change" },
  // ],
  // ruleLowestNum: [
  //   { required: true, message: "请输入计算样本最低数量", trigger: "change" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // ruleLowestDuration: [
  //   {
  //     required: true,
  //     message: "请输入计算最低取样时长(天)",
  //     trigger: "change",
  //   },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // continuousNum: [
  //   { required: true, message: "请输入数量", trigger: "change" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // intervalSecond: [
  //   { required: true, message: "请输入节拍比对倍数", trigger: "change" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // firstExecutionTime: [
  //   { required: true, message: "请选择首次执行时间", trigger: "change" },
  // ],
  // intervalHour: [
  //   { required: true, message: "请输入取样间隔（小时）", trigger: "change" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // cpkComputeHour: [
  //   { required: true, message: "请输入CPK计算周期（小时）", trigger: "change" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // maxRange: [
  //   { required: true, message: "请输入取样最大范围", trigger: "change" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // minRange: [
  //   { required: true, message: "请输入取样最大范围", trigger: "change" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // rollInterval: [
  //   { required: true, message: "请输入取样范围滚动间隔", trigger: "change" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // maxUnit: [
  //   { required: true, message: "请选择取样最大范围单位", trigger: "change" },
  // ],

  // sampleNum: [
  //   { required: true, message: "请输入", trigger: "blur" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // /**
  //  * 是否预警(单值,均值,长期,阶段, 特殊)
  //  */
  // isWarn: [{ required: true, message: "请选择", trigger: "change" }],
  // /**
  //  * 连续超过控制限次数(单值,均值,长期)
  //  */
  // controlRate: [
  //   { required: true, message: "请输入", trigger: "blur" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // /**
  //  * 上限比例(单值)
  //  */
  // upLine: [
  //   { required: true, message: "请输入", trigger: "blur" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // /**
  //  * 下限比例(单值)
  //  */
  // downLine: [
  //   { required: true, message: "请输入", trigger: "blur" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // /**
  //  * 分组测量值个数(均值)
  //  */
  // groupingNum: [
  //   { required: true, message: "请输入", trigger: "blur" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // /**
  //  * 默认高于值(阶段, 特殊)
  //  */
  // defaultTall: [
  //   { required: true, message: "请输入", trigger: "blur" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // /**
  //  * 连续高于次数(阶段, 特殊)
  //  */
  // tallStopover: [
  //   { required: true, message: "请输入", trigger: "blur" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // /**
  //  * 连续高于值(阶段, 特殊)
  //  */
  // successiveTall: [
  //   { required: true, message: "请输入", trigger: "blur" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // /**
  //  * 连续低于次数(阶段, 特殊)
  //  */
  // lowStopover: [
  //   { required: true, message: "请输入", trigger: "blur" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // /**
  //  * 默认低于值(阶段, 特殊)
  //  */
  // defaultLow: [
  //   { required: true, message: "请输入", trigger: "blur" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // /**
  //  * 首次调查时间(长期, 阶段, 特殊)
  //  */
  // checkHour: [
  //   { required: true, message: "请输入", trigger: "blur" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // /**
  //  * 更新时间(长期, 阶段, 特殊)
  //  */
  // updateHour: [
  //   { required: true, message: "请输入", trigger: "blur" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
  // /**
  //  * 升级次数(长期, 阶段, 特殊)
  //  */
  // escalateStopover: [
  //   { required: true, message: "请输入", trigger: "blur" },
  //   {
  //     pattern: /^(0|[1-9][0-9]*)$/,
  //     message: "只能请输入正整数",
  //     trigger: "blur",
  //   },
  // ],
});

const formRef = ref(ElForm);

let formData = reactive<any>({
  id: "",
  processId: "",
  processCode: "",
  processName: "",
  equipId: "",
  equipCode: "",
  equipName: "",
  projectId: "",
  projectCode: "",
  projectName: "",
  modelId: "",
  modelCode: "",
  modelName: "",
  gageEquipId: "",
  gageEquipCode: "",
  gageEquipName: "",
  gageEquipMarkId: "",
  gageEquipMarkCode: "",
  gageEquipMarkName: "",
  paramId: "",
  paramCode: "",
  paramName: "",
  checkType: "",
  parameterStandards: "",
  responsibleUserName: "",
  workshopSectionCode: "",
  lowerLimitValue: "",
  upperLimitValue: "",
  controlRatioUp: "",
  controlRatioDown: "",
  controlUp: "",
  controlDown: "",
  isRatioUp: false,
  isRatioDow: false,
  isSingle: false,
  isAverage: false,
  isLong: false,
  isStage: true,
  isFeatures: false,
  isSingleOrder: false,
  isAverageOrder: false,
  isLongOrder: false,
  isStageOrder: true,
  isFeaturesOrder: false,
  isCalculate: false,
  version: "",
  enabled: "",
  deleted: "",
  createTime: "",
  createdUserId: "",
  createdUserName: "",
  lastUpdatedUserId: "",
  lastUpdatedUserName: "",
  lastUpdateTime: "",
  remarks: "",
  orderId: "",
  useType: "",
  samplingFrequency: "100%",
  changeInfo: "",
  shaftSuffixIds: "",
  shaftSuffixNames: "",
  shaftSuffixCodes: "",
  shaftSuffixIdsTwo: [],
  groupCode: "",
  groupName: "",
});

// 预警工单
const selectAllWo = ref(false);

// 预警工单 全选
function handleCheckAllWoChange(e) {
  for (let i = 0; i < tabsList.value.length; i++) {
    formData[`${tabsList.value[i].labelValue}Order`] = e ? true : false;
  }
}

function hasTag(name: string) {
  const current = tabsList.value.filter((e) => e.label == name);
  if (current && current?.length) {
    return true;
  } else {
    return false;
  }
}

// 预警工单 回显
function handleCheckAllChange1() {
  let result = true;
  for (let i = 0; i < tabsList.value.length; i++) {
    if (!formData[`${tabsList.value[i].labelValue}Order`]) {
      result = false;
    }
  }
  selectAllWo.value = result;
}

// 预警邮件
const selectAllEm = ref(false);

// 预警邮件 全选
function handleCheckAllEmChange(e) {
  for (let i = 0; i < tabsList.value.length; i++) {
    formData[tabsList.value[i].labelValue] = e ? true : false;
  }
}

// 预警邮件 回显
function handleCheckAllChange2() {
  let result = true;
  for (let i = 0; i < tabsList.value.length; i++) {
    if (!formData[tabsList.value[i].labelValue]) {
      result = false;
    }
  }
  selectAllEm.value = result;
}
let oldFormData = {};

watch(
  () => props.data,
  (newVal: any) => {
    formData.id = "";
    if (newVal?.id) {
      const {
        id,
        processId,
        processCode,
        processName,
        equipId,
        equipCode,
        equipName,
        projectId,
        projectCode,
        projectName,
        modelId,
        modelCode,
        modelName,
        gageEquipId,
        gageEquipCode,
        gageEquipName,
        gageEquipMarkId,
        gageEquipMarkCode,
        gageEquipMarkName,
        paramId,
        paramCode,
        paramName,
        checkType,
        parameterStandards,
        responsibleUserName,
        lowerLimitValue,
        upperLimitValue,
        controlRatioUp,
        controlRatioDown,
        controlUp,
        controlDown,
        isRatioUp,
        isRatioDow,
        isSingle,
        isAverage,
        isLong,
        isStage,
        isFeatures,
        isSingleOrder,
        isAverageOrder,
        isLongOrder,
        isStageOrder,
        isFeaturesOrder,
        isCalculate,
        version,
        enabled,
        deleted,
        createTime,
        createdUserId,
        createdUserName,
        lastUpdatedUserId,
        lastUpdatedUserName,
        lastUpdateTime,
        remarks,
        orderId,
        useType,
        workshopSectionCode,
        shaftSuffixIds,
        shaftSuffixNames,
        shaftSuffixCodes,
        shaftSuffixIdsTwo,
        groupCode,
        groupName,
      } = newVal;
      Object.assign(formData, {
        id,
        processId,
        processCode,
        processName,
        equipId,
        equipCode,
        equipName,
        projectId,
        projectCode,
        projectName,
        modelId,
        modelCode,
        modelName,
        gageEquipId,
        gageEquipCode,
        gageEquipName,
        gageEquipMarkId,
        gageEquipMarkCode,
        gageEquipMarkName,
        paramId,
        paramCode,
        paramName,
        checkType,
        parameterStandards,
        responsibleUserName,
        lowerLimitValue,
        upperLimitValue,
        controlRatioUp,
        controlRatioDown,
        controlUp,
        controlDown,
        isRatioUp,
        isRatioDow,
        isSingle,
        isAverage,
        isLong,
        isStage,
        isFeatures,
        isSingleOrder,
        isAverageOrder,
        isLongOrder,
        isStageOrder,
        isFeaturesOrder,
        isCalculate: isCalculate == 1,
        version,
        enabled,
        deleted,
        createTime,
        createdUserId,
        createdUserName,
        lastUpdatedUserId,
        lastUpdatedUserName,
        lastUpdateTime,
        remarks: "",
        orderId,
        useType,
        workshopSectionCode,
        shaftSuffixIds,
        shaftSuffixNames,
        shaftSuffixCodes,
        shaftSuffixIdsTwo,
        groupCode,
        groupName,
      });

      getPcmConfigMeasurementsDTOList();

      tabSelected.value = useType == "2" ? "singleHundred" : "single";
      tabSelecteds.value = "基础信息";
      getRemarks(id);
      getWorkOrderList(paramId);
      setTimeout(() => {
        // 工单全选判断
        handleCheckAllChange1();
        // 邮件全选判断
        handleCheckAllChange2();
      }, 500);
      // formData.shaftSuffixIdsTwo = formData.shaftSuffixIds.split(",") || [];
      oldFormData = JSON.parse(JSON.stringify(formData));
    }
  }
);
const tabSelecteds = ref("基础信息");
// tabSelected.value = toolUseType == "2" ? "singleHundred" : "single";
/** 关闭表单弹窗 */
function closeDialog() {
  visibleDialog.value = false;
  emit("reset-table", formData.id);
  emit("change-visible", false);
  resetForm();
}

/** 重置表单 */
function resetForm() {
  formRef.value.resetFields();
  formRef.value.clearValidate();
  formData.id = "";
  formData.processId = "";
  formData.processCode = "";
  formData.processName = "";
  formData.equipId = "";
  formData.equipCode = "";
  formData.equipName = "";
  formData.projectId = "";
  formData.projectCode = "";
  formData.projectName = "";
  formData.modelId = "";
  formData.modelCode = "";
  formData.modelName = "";
  formData.gageEquipId = "";
  formData.gageEquipCode = "";
  formData.gageEquipName = "";
  formData.gageEquipMarkId = "";
  formData.gageEquipMarkCode = "";
  formData.gageEquipMarkName = "";
  formData.paramId = "";
  formData.paramCode = "";
  formData.paramName = "";
  formData.checkType = "";
  formData.parameterStandards = "";
  formData.responsibleUserName = "";
  formData.lowerLimitValue = "";
  formData.upperLimitValue = "";
  formData.controlRatioUp = "";
  formData.controlRatioDown = "";
  formData.controlUp = "";
  formData.controlDown = "";
  formData.isRatioUp = false;
  formData.isRatioDow = false;
  formData.isSingle = false;
  formData.isAverage = false;
  formData.isLong = false;
  formData.isStage = false;
  formData.isFeatures = false;
  formData.isSingleOrder = false;
  formData.isAverageOrder = false;
  formData.isLongOrder = false;
  formData.isStageOrder = false;
  formData.isFeaturesOrder = false;
  formData.isCalculate = false;
  formData.version = "";
  formData.enabled = "";
  formData.deleted = "";
  formData.createTime = "";
  formData.createdUserId = "";
  formData.createdUserName = "";
  formData.lastUpdatedUserId = "";
  formData.lastUpdatedUserName = "";
  formData.lastUpdateTime = "";
  formData.remarks = "";
  formData.orderId = "";
  formData.workshopSectionCode = "";
  formData.shaftSuffixIds = "";
  formData.shaftSuffixNames = "";
  formData.shaftSuffixCodes = "";
  formData.shaftSuffixIdsTwo = [];
  formData.groupCode = "";
  formData.groupName = "";
  remarkList.value = [];
}
// 比较
// 两个对象是否相同的浅比较
function shallowCompare(obj1: any, obj2: any) {
  const differences: any = {};
  const keys = new Set([...Object.keys(obj1), ...Object.keys(obj2)]);
  keys.forEach((key) => {
    if (obj1[key] != obj2[key]) {
      if (
        key != "remarkList" &&
        key != "shaftSuffixIdsTwo" &&
        key != "pcmConfigMeasurementsDTOList" &&
        key != "shaftSuffixIds" &&
        key != "shaftSuffixNames" &&
        key != "remarks" &&
        key != "tabsReal" &&
        key != "tabsOld" &&
        key != "diffData" &&
        key != "changeInfo"
      ) {
        differences[key] = {
          value1: obj1[key],
          value2: obj2[key],
        };
        differences[key].label = obj1.label ? obj1.label : "基础信息";
        differences[key].isNotStage = obj1.abilityType !== "3";
        differences[key].name = filterLable(
          key,
          differences[key].isNotStage,
          differences[key].value2
        );
      }
    }
  });
  return differences;
}

function filterLable(name: string, isNotStage: boolean, value: any) {
  const configObject: any = {
    countRuleCode: "取样规则编码",
    abilityType: "过程质量监控分类",
    ruleLowestNum: "计算样本最低数量",
    ruleLowestDuration: "计算最低取样时长(天)",
    continuousNum: `${isNotStage ? "滚动数量" : "样本节拍比对件数"}`,
    intervalSecond: "节拍比对倍数",
    firstExecutionTime: "首次执行时间",
    intervalHour: "取样间隔（小时）",
    cpkComputeHour: "CPK计算周期（小时）",
    maxRange: "取样最大范围",
    minRange: "取样最小范围",
    rollInterval: "取样范围滚动间隔",
    maxUnit: "取样范围单位",
    sampleNum: "单值默认展示数量",
    isWarn: "是否预警",
    controlRate: "预警触发：连续超过控制限次数",
    upLine: "控制线上限收严比例",
    downLine: "控制线下限收严比例",
    groupingNum: "子组样本数量",
    defaultTall: `过程能力趋势图cpk均高于${value}`,
    tallStopover: `cpk连续${value}次`,
    successiveTall: `高于${value}以上`,
    lowStopover: `cpk连续${value}次呈持续下降趋势`,
    defaultLow: `过程能力趋势图cpk均高于${value}`,
    checkHour: "首次调查时间",
    updateHour: "更新时间",
    escalateStopover: "升级次数",
    enabled: "是否启用",
    memo: "监控描述",
    tooltoolUseType: "检具用途",
    cpkLow: `趋势图中cpk值低于${value}`,
    ppkLow: `趋势图中ppk值低于${value}`,
    isEmail: "是否发送邮件",
    isOrder: "是否生成工单",
    maxCount: "取样数据集上限",
    controlRatioDown: "控制线下限收严比例",
    controlRatioUp: "控制线上限收严比例",
    controlUp: "控制限上限",
    controlDown: "控制限下限",
    isAverage: "发送邮件-均值",
    isAverageOrder: "生成工单-均值",
    isFeatures: "发送邮件-子类别过程能力",
    isFeaturesOrder: "生成工单-子类别过程能力",
    isCalculate: "CPK计算",
    isLong: "发送邮件-长期过程能力",
    isLongOrder: "生成工单-长期过程能力",

    isSingle: "发送邮件-单值",
    isSingleOrder: "生成工单-单值",
    isStage: "发送邮件-短期能力",
    isStageOrder: "生成工单-短期能力",
    shaftSuffixIds: "测量后缀",
    shaftSuffixNames: "测量后缀",
    shaftSuffixCodes: "测量后缀",
    shaftSuffixIdsTwo: "测量后缀",
  };
  return configObject[name] ?? "";
}

const dialogVisible = ref(false);
const diffData = ref(<any>[]);
const tabsReal = ref(<any>[]);
const open = () => {
  let hh = [];
  tabs.value.forEach((item, index) => {
    let shaftSuffixNames = [];
    let shaftSuffixCodes = [];
    let shaftSuffixIds = [];
    if (item.shaftSuffixIdsTwo?.length > 0) {
      specialInspectionList.value.forEach((element) => {
        item?.shaftSuffixIdsTwo.forEach((item) => {
          if (element.id == item) {
            shaftSuffixIds.push(element.id);
            shaftSuffixNames.push(element.featureName);
            shaftSuffixCodes.push(element.shaftSuffix);
          }
        });
      });

      item.shaftSuffixIds = shaftSuffixIds.join(",") || "";
      item.shaftSuffixCodes = shaftSuffixCodes.join(",") || "";
      item.shaftSuffixNames = shaftSuffixNames.join(",") || "";
    }

    const diff = shallowCompare(toRaw(tabsOld[index]), toRaw(item));
    hh.push(diff);
  });

  hh.push(shallowCompare(toRaw(oldFormData), toRaw(formData)));

  dialogVisible.value = true;

  diffData.value = hh || {};

  const arr1 = tabs.value.filter((t) => t.toolUseType == formData.useType);
  const arr = [
    {
      label: "基础信息",
    },
    ...arr1,
  ];
  //   v-for="(item1, index) in tabs.filter(
  //           (t) => t.toolUseType == formData.useType
  //         )"

  let newArr: any = [];
  for (let i = 0; i < arr.length; i++) {
    for (let j = 0; j < diffData.value.length; j++) {
      //   console.log(
      //     "diffData.value[j]",
      //     diffData.value,
      //     j,
      //     JSON.stringify(diffData.value[j])
      //   );
      if (JSON.stringify(diffData.value[j]) != "{}") {
        // console.log(
        //   arr[i].label,
        //   diffData.value[j][Object.keys(diffData.value[j])[0]]
        // );
        if (
          arr[i].label.includes(
            diffData.value[j][Object.keys(diffData.value[j])[0]].label
          )
        ) {
          newArr.push(arr[i].label);
          //   return;
        }
      }
    }
  }
  tabsReal.value = newArr;
  //   arr.map((e) => {
  //     diffData.value.map(self => {
  //         if (e.id == self.id) {
  //           newArr.push(self);
  //         }
  //     } )
  //   });

  // ElMessageBox.prompt("变更履历", "提示", {
  //   confirmButtonText: "确定",
  //   cancelButtonText: "取消",
  //   inputPattern: /^(?!\s*$).{1,250}$/,
  //   inputErrorMessage: "变更履历不能为空，且不能超过250个字符",
  //   inputPlaceholder: "请填写变更履历",
  //   inputType: "textarea",
  // })
  //   .then(({ value }) => {
  //     // console.log("确定", value);
  //     formData.remarks = value;
  //     saveInfo();
  //   })
  //   .catch(() => {
  //     ElMessage({
  //       type: "info",
  //       message: "已取消",
  //     });
  //   });
};

const loading = ref(false);

/** 测量特性定义保存提交 */
function handleSubmit() {
  if (formData.isRatioUp && !formData.controlRatioUp)
    return ElMessage.error("请输入控制线上限收严比例");
  if (formData.isRatioDow && !formData.controlRatioDown)
    return ElMessage.error("请输入控制线下限收严比例");
  formRef.value.validate(async (valid: any) => {
    if (valid) {
      open();
    }
  });
}

async function saveInfo() {
  if (!formData.remarks) {
    ElMessage.warning("请填写变更内容说明！");
    return;
  }

  for (let i = 0; i < tabs.value.length; i++) {
    if (tabs.value[i].programId) {
      if (
        tabs.value[i].label == "单值" &&
        (!tabs.value[i].upLine ||
          !tabs.value[i].sampleNum ||
          !tabs.value[i].maxCount ||
          !tabs.value[i].downLine ||
          !tabs.value[i].controlRate ||
          !tabs.value[i].memo)
      ) {
        ElMessage.warning(`单值中的数据不完整！`);
        return;
      } else if (
        tabs.value[i].label == "均值" &&
        (!tabs.value[i].controlRate ||
          !tabs.value[i].groupingNum ||
          !tabs.value[i].maxCount ||
          !tabs.value[i].sampleNum ||
          !tabs.value[i].memo)
      ) {
        ElMessage.warning(`均值中的数据不完整！`);
        return;
      } else if (
        // 长期抽检
        tabs.value[i].label == "长期过程能力" &&
        tabs.value[i].toolUseType == "1" &&
        (!tabs.value[i].memo ||
          !tabs.value[i].ppkLow ||
          !tabs.value[i].cpkLow ||
          !tabs.value[i].maxUnit ||
          !tabs.value[i].minRange ||
          !tabs.value[i].maxRange ||
          !tabs.value[i].cpkComputeHour ||
          !tabs.value[i].ruleLowestNum ||
          !tabs.value[i].ruleLowestDuration ||
          !tabs.value[i].firstExecutionTime ||
          !tabs.value[i].shaftSuffixIds ||
          !tabs.value[i].shaftSuffixNames ||
          !tabs.value[i].shaftSuffixCodes)
      ) {
        ElMessage.warning(`长期过程能力中的数据不完整！`);
        return;
      } else if (
        // 长期百检
        tabs.value[i].label == "长期过程能力" &&
        tabs.value[i].toolUseType == "2" &&
        (!tabs.value[i].memo ||
          !tabs.value[i].ppkLow ||
          !tabs.value[i].cpkLow ||
          !tabs.value[i].maxUnit ||
          !tabs.value[i].maxRange ||
          !tabs.value[i].cpkComputeHour ||
          !tabs.value[i].ruleLowestNum ||
          !tabs.value[i].intervalSecond ||
          !tabs.value[i].continuousNum ||
          !tabs.value[i].intervalHour ||
          !tabs.value[i].firstExecutionTime)
      ) {
        ElMessage.warning(`长期过程能力中的数据不完整！`);
        return;
      } else if (
        tabs.value[i].label == "短期能力" &&
        (!tabs.value[i].ruleLowestNum ||
          !tabs.value[i].continuousNum ||
          !tabs.value[i].cpkLow ||
          !tabs.value[i].ppkLow ||
          !tabs.value[i].defaultTall ||
          !tabs.value[i].tallStopover ||
          !tabs.value[i].successiveTall ||
          !tabs.value[i].defaultLow ||
          !tabs.value[i].lowStopover ||
          !tabs.value[i].memo)
      ) {
        ElMessage.warning(`短期能力中的数据不完整！`);
        return;
      } else if (
        tabs.value[i].label == "子类别过程能力" &&
        (!tabs.value[i].cpkLow ||
          !tabs.value[i].ppkLow ||
          !tabs.value[i].defaultTall ||
          !tabs.value[i].tallStopover ||
          !tabs.value[i].successiveTall ||
          !tabs.value[i].defaultLow ||
          !tabs.value[i].lowStopover ||
          !tabs.value[i].memo ||
          !tabs.value[i].firstExecutionTime ||
          !tabs.value[i].ruleLowestDuration ||
          !tabs.value[i].ruleLowestNum ||
          !tabs.value[i].cpkComputeHour ||
          !tabs.value[i].maxRange ||
          !tabs.value[i].maxUnit)
      ) {
        ElMessage.warning(`子类别过程能力中的数据不完整！`);
        return;
      }
    }
  }

  formData.pcmConfigMeasurementsDTOList = JSON.parse(
    JSON.stringify(
      tabs.value.filter((item) => item.toolUseType == formData.useType)
    )
  );

  loading.value = true;
  const text = formData.id ? "编辑" : "新增";

  let params = JSON.parse(JSON.stringify(formData));

  params.isRatioUp = formData.isRatioUp ? 1 : 0;
  params.isRatioDow = formData.isRatioDow ? 1 : 0;
  params.isSingle = formData.isSingle ? 1 : 0;
  params.isAverage = formData.isAverage ? 1 : 0;
  params.isLong = formData.isLong ? 1 : 0;
  params.isStage = formData.isStage ? 1 : 0;
  params.isFeatures = formData.isFeatures ? 1 : 0;
  params.isSingleOrder = formData.isSingleOrder ? 1 : 0;
  params.isAverageOrder = formData.isAverageOrder ? 1 : 0;
  params.isLongOrder = formData.isLongOrder ? 1 : 0;
  params.isStageOrder = formData.isStageOrder ? 1 : 0;
  params.isFeaturesOrder = formData.isFeaturesOrder ? 1 : 0;
  params.isCalculate = formData.isCalculate ? 1 : 0;
  // 变更履历详情
  let changeInfoText = {
    tabs: toRaw(tabsReal.value),
    diff: toRaw(diffData.value),
  };
  params.changeInfo = JSON.stringify(changeInfoText);
  await request({
    url: "/dmpDosPcm/pcmmeasurefeaturesgroup/save",
    method: "post",
    data: params,
  })
    .then(() => {
      loading.value = false;
      getRemarks(formData.id);
    })
    .finally(() => {
      loading.value = false;
      dialogVisible.value = false;
    });

  ElMessage.success(text + `成功`);
  // emit("reset-table", formData.id);
  // closeDialog();
}

// 组件销毁时调用
onBeforeUnmount(() => {
  visibleDialog.value = false;
  emit("change-visible", false);
});

onMounted(() => {
  getProcessList();
  queryEquipList();
  getSpecialInspectionList();
});

// 获取工序
const processList = ref([]);
const getProcessList = async () => {
  const res = await request({
    url: `/mdm/mdmprocess/getList`,
    method: "post",
    data: {},
  });
  processList.value = res.data;
};

const queryEquipList = async () => {
  const { data } = await request({
    url: "/mdm/mdmprocessequip/getList",
    method: "POST",
    data: {
      enabled: 1,
    },
  });
  const equipOptions = ref([]);
  equipOptions.value = data;
};

function controlRatioUpChange(input: any) {}

function numValidcontrolRatioUp() {
  if (formData.controlRatioUp >= 100) {
    formData.controlRatioUp = 99;
  }

  let checkdata = formData.controlRatioUp;

  if (
    !formData.upperLimitValue ||
    !formData.lowerLimitValue ||
    formData.upperLimitValue == 0 ||
    formData.lowerLimitValue == 0
  ) {
    formData.controlUp = 0;
  } else {
    formData.controlUp =
      formData.upperLimitValue -
      (formData.upperLimitValue - formData.lowerLimitValue) * (checkdata / 100);
  }
}

function numValidcontrolRatioDown() {
  if (formData.controlRatioDown >= 100) {
    formData.controlRatioDown = 99;
  }

  let checkdata = formData.controlRatioDown;

  if (
    !formData.upperLimitValue ||
    !formData.lowerLimitValue ||
    formData.upperLimitValue == 0 ||
    formData.lowerLimitValue == 0
  ) {
    formData.controlDown = 0;
  } else {
    formData.controlDown =
      formData.lowerLimitValue +
      (formData.upperLimitValue - formData.lowerLimitValue) * (checkdata / 100);
  }
}

const tabSelected = ref("singleHundred");

const tabs = ref([
  {
    label: "单值",
    name: "singleHundred",
    abilityType: "0",
    abilityTypeElder: "0",
    toolUseType: "2",
    labelValue: "isSingle",
  },
  {
    label: "单值",
    name: "single",
    abilityType: "0",
    abilityTypeElder: "0",
    toolUseType: "1",
    labelValue: "isSingle",
  },
  {
    label: "均值",
    name: "averageHundred",
    abilityType: "2",
    abilityTypeElder: "2",
    toolUseType: "2",
    labelValue: "isAverage",
  },
  {
    label: "均值",
    name: "average",
    abilityType: "2",
    abilityTypeElder: "2",
    toolUseType: "1",
    labelValue: "isAverage",
  },
  {
    label: "长期过程能力",
    name: "longHundred",
    abilityType: "4",
    abilityTypeElder: "4",
    toolUseType: "2",
    labelValue: "isLong",
  },
  {
    label: "长期过程能力",
    name: "long",
    abilityType: "4",
    abilityTypeElder: "4",
    toolUseType: "1",
    labelValue: "isLong",
  },
  {
    label: "短期能力",
    name: "stage",
    abilityType: "6",
    abilityTypeElder: "6",
    toolUseType: "1",
    labelValue: "isStage",
  },
  // {
  //   label: "子类别过程能力",
  //   name: "special",
  //   abilityType: "7",
  //   abilityTypeElder: "7",
  //   toolUseType: "1",
  //   labelValue: "isFeatures",
  // },
]);

const tabsList = ref<any>([]);
let tabsOld = [];
const getPcmConfigMeasurementsDTOList = async () => {
  const { data } = await request({
    url: `/dmpDosPcm/pcmconfigmeasurements/getByProgramId`,
    method: "get",
    params: { programId: formData.id, useType: formData.useType },
  });
  tabs.value.forEach((item) => {
    const find = data.find(
      (t) =>
        t.abilityType == item.abilityType && t.toolUseType == item.toolUseType
    );
    Object.assign(item, find);
    item.maxUnit = item?.maxUnit?.toString();
    item.abilityType = item?.abilityType?.toString();
  });
  const { data: remarksData } = await request({
    url: `/dmpDosPcm/pcmconfigmeasurements/getRecordRemarksByProgram`,
    method: "get",
    params: { id: formData.id },
  });
  tabs.value.forEach((item) => {
    const find = remarksData.filter(
      (t) =>
        t.abilityType == item.abilityType && t.toolUseType == item.toolUseType
    );
    item.remarkList = find;
    item.shaftSuffixIdsTwo = item.shaftSuffixIds?.split(",");
  });

  tabsList.value =
    tabs.value.filter((t) => t.toolUseType == formData.useType) || [];

  tabsOld = JSON.parse(JSON.stringify(tabs.value));
};

/** 测量数据取样配置保存提交 */
async function configSubmit(item) {
  formRef.value.validate(async (valid: any) => {
    if (valid) {
      loading.value = true;
      const text = item.id ? "编辑" : "保存";
      item.programId = formData.id;
      await request({
        url: "/dmpDosPcm/pcmconfigmeasurements/save",
        method: "post",
        data: item,
      }).finally(() => {
        loading.value = false;
      });
      ElMessage.success(text + `成功`);
      getPcmConfigMeasurementsDTOList();
    }
  });
}

const saveItem = (item) => {
  ElMessageBox.confirm(
    `是否保存特性为${formData.paramName}的${item.label}配置?`,
    "警告",
    {
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      type: "warning",
    }
  ).then(async () => {
    configSubmit(item);
  });
};

const deleteItem = (item) => {
  // console.log("deleteItem", item);
  ElMessageBox.confirm(
    `是否重置特性为${formData.paramName}的${item.label}配置?`,
    "提示",
    {
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      type: "warning",
    }
  ).then(async () => {
    await request({
      url: `/dmpDosPcm/pcmconfigmeasurements/deleteItem/${item.id}`,
      method: "post",
    }).then(() => {
      ElMessage.success("重置成功");
      getPcmConfigMeasurementsDTOList();
    });
  });
};

const mockChangeInfo = {
  tabs: ["单值"],
  diff: [
    {},
    {
      sampleNum: {
        value1: 50,
        value2: "500",
        label: "单值",
        isNotStage: true,
        name: "单值默认展示数量",
      },
      downLine: {
        value1: 10,
        value2: "100",
        label: "单值",
        isNotStage: true,
        name: "控制线下限收严比例",
      },
    },
    {},
    {},
    {},
    {},
    {},
    {},
    {},
  ],
};
const remarkList = ref([]);

async function getRemarks(id: string) {
  const res: any = await request({
    url: "/dmpDosPcm/pcmmeasurefeaturesrecord/getByMeasureFeaturesId",
    method: "get",
    params: { measureFeaturesId: id },
  }).catch(() => {});
  let a = res.data;
  a?.forEach((e) => {
    e.changeInfo = JSON.parse(e.changeInfo);
  });
  remarkList.value = a || [];
}

// 排序
const showOperationRecord = () => {
  if (remarkList.value.length > 0) {
    remarkList.value.reverse();
  }
};

// 折叠
const activeName = ref("单值");

const workOrderList = ref<any>([]);

async function getWorkOrderList(id: string) {
  workOrderList.value = [];
  const res: any = await request({
    url: "/dmpDosPcm/pcmWorkOrder/getByFeature",
    method: "post",
    data: { paramId: id },
  }).catch(() => {});
  workOrderList.value = res.data ?? [];
}

// 工单详情弹窗功能如下------------
const addDialog = reactive<DialogOption>({
  visible: false,
  readvisible: false,
  title: "",
  data: {},
});

// 查询工单详情
async function getInfo(id: string) {
  request({
    url: `/dmpDosPcm/pcmworkorder/get/${id}`,
    method: "get",
  })
    .then((data) => {
      addDialog.data = data.data;
      addDialog.visible = true;
    })
    .catch((res) => {
      console.log(res);
    });
}

const dayjsValue = ref(dayjs().valueOf());

/** 打开工单管理表单弹窗 详情 */
function openDialogdetail(roleObj?: any) {
  if (roleObj.id) {
    addDialog.title = "工单管理详情";
    getInfo(roleObj.id);
    addDialog.readvisible = true;
  }
}

function changeVisible(value: boolean) {
  addDialog.visible = value;
  if (!value) {
    addDialog.data = {};
  }
}

// 获取特性送检列表
const specialInspectionList = ref<Array<object>>([]);
const getSpecialInspectionList = async () => {
  await request({
    url: "/dmpDosPcm/pcmspecialrule/getList",
    method: "post",
    data: {},
  }).then((res) => {
    specialInspectionList.value = res.data;
    // console.log(" specialInspectionList.value", specialInspectionList.value);
  });
};
</script>
<style lang="scss" scoped>
:deep(.el-dialog__body) {
  padding: 20px;
  max-height: calc(100vh - 120px - 40px - 40px);
  overflow-y: auto;
}

:deep(.el-descriptions__label.el-descriptions__cell.is-bordered-label) {
  width: 80px;
  font-size: 13px;
  padding: 5px 7px;
}

:deep(.warning-select) {
  .el-form-item {
    margin-bottom: 3px;
  }

  .el-checkbox {
    margin-right: 18px;
  }

  .el-checkbox__label {
    padding-left: 5px;
  }
}

.yellow-icon {
  .el-icon {
    margin-top: 8px;
    margin-left: 5px;
    font-size: 16px;
    color: #999;
  }
}

.readForm {
  :deep(.el-form-item) {
    margin-bottom: 3px !important;
  }
}
</style>
